package com.wz.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.util.Log;

import com.wz.fragment.ContactListFragment;
import com.wz.fragment.FestivalCategoryFragment;
import com.wz.fragment.SmsHistoryFragment;

public class ViewPagerAdapter extends FragmentPagerAdapter{
	
	private String[] titles;
	
	public ViewPagerAdapter(FragmentManager fm) {
		super(fm);
	}
	
	public ViewPagerAdapter(FragmentManager fm,String[] titles) {
		super(fm);
		this.titles = titles;
	}

	@Override
	public Fragment getItem(int position) {
		
		Log.d("Tag", "new  FestivalCategoryFragment() ");
		if(position == 0){
			return new ContactListFragment();
		}else if(position == 1){
			return new FestivalCategoryFragment();
		}else if(position == 2){
			return new SmsHistoryFragment();
		}else{
			throw new IllegalArgumentException("fragment 使用错误");
		}
	}

	@Override
	public int getCount() {
		return titles.length;
	}
	
	@Override
	public CharSequence getPageTitle(int position) {
		return titles[position];
	}

}
